package test;

import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.*;
import org.apache.hadoop.hbase.client.*;
import java.io.IOException;

public class List{
    public static Configuration configuration;
    public static Connection connection;
    public static Admin admin;
    public static void init(){
        configuration=HBaseConfiguration.create();
        configuration.set("hbase.rootdir", "hdfs://localhost:9000/hbase");
        try {
        	connection=ConnectionFactory.createConnection(configuration);
        	admin=connection.getAdmin();
        }catch(IOException e) {
        	e.printStackTrace();
        }
    }
    public static void close() {
    	try {
    		if(admin!=null)
    			admin.close();
    		if(null!=connection)
    			connection.close();
    	}catch(IOException e) {
        	e.printStackTrace();
        }
    }
    public static void listTables() throws IOException{
    	init();
    	HTableDescriptor hTableDescriptors[]=admin.listTables();
    	for(HTableDescriptor hTableDescriptor:hTableDescriptors) {
    		System.out.println(hTableDescriptor.getNameAsString());
    	}
    	close();
    }
    public static void main(String[] args) {
		List t=new List();
		try {
			t.listTables();
		}catch(IOException e) {
        	e.printStackTrace();
        }
	}
}